package com.example.hellodemo.fragement;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.hellodemo.R;

public class AFragement extends Fragment {
    @Nullable

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragement_a,container,false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        TextView textView = view.findViewById(R.id.fragement_a);
        textView.setText("我是AFragement");
        if (getArguments() != null){
            textView.setText(getArguments().getString("title"));
        }
    }


    @Override
    public void onAttach(@NonNull Context context) {  // Activity 与 Fragement 绑定关系时调用
        super.onAttach(context);
        Log.d("AFragement","...onAttach...");
    }

    @Override
    public void onDetach() {   // Activity 与 Fragement 解除关系时调用     注意 一旦解除了关系 getActivity()就是null 要注意安全判断
        super.onDetach();
        Log.d("AFragement","...onDetach...");

    }

    @Override
    public void onDestroy() {   // Fragement销毁时调用
        super.onDestroy();
        Log.d("AFragement","...onDestroy...");

    }
}
